package material.command.undo;

import material.command.receiver_命令接收者.Light;

public class RemoteLoader {
    public static void main(String[] args) {

        Light livingRoomLight = new Light("卧室");//声明电灯实例
        /**创建开和关两个电灯指令**/
        LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
        LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
        RemoteControlWithUndo remoteControl = new RemoteControlWithUndo();//声明一个遥控器
        remoteControl.setCommand(0, livingRoomLightOn,
                livingRoomLightOff);//将电灯的命令设置到0号插槽
        /**下面依次执行开灯，关灯，撤销按钮**/
        System.out.println("----------------开灯，关灯，撤销----------------");
        remoteControl.onButtonWasPushed(0);
        remoteControl.offButtonWasPushed(0);
        remoteControl.undoButtonWasPushed();
        /**下面依次执行关灯，开灯,撤销按钮**/
        System.out.println("----------------关灯，开灯,撤销----------------");
        remoteControl.offButtonWasPushed(0);
        remoteControl.onButtonWasPushed(0);
        remoteControl.undoButtonWasPushed();
    }
}
